package com.example.demo;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Copyright (C), 2015-2019
 * FileName: TestApi
 * Author:   MRC
 * Date:     2019/12/25 17:51
 * Description:
 * History:
 */
@RestController
@RequestMapping("/")
public class TestApi {


    @Autowired
    private DiscoveryClient discoveryClient;

    @GetMapping("/list")
    @HystrixCommand(fallbackMethod = "serviceCallBack")
    public String print() {

        System.out.println("service" + discoveryClient.getServices());

        return "Eureka Client";
    }

    public String serviceCallBack() {
        return "error";
    }

}